package b3.widget.vip
{
	import b3.config.*;
	import b3.net.*;
	import b3.util.*;
	import b3.widget.*;
	import b3.widget.basic.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.text.*;
	
	public class VipPrivilegesDialog extends BasicWidget
	{
		private const dailyPresent:Array = ["323_1", "323_2", "323_3", "323_3,303_1", "323_3,303_2", "323_3,303_3", "323_4,303_3"];
		
		public function VipPrivilegesDialog()
		{
			super();
			//对话框背景
			var VipPrivilegesDialogBgr:Class = ResourceHelper.getInstance().getClassByName("VipPrivilegesDialogBgr");
			addChild(new VipPrivilegesDialogBgr());
			//关闭按钮
			var VipButtonClose1:Class = ResourceHelper.getInstance().getClassByName("VipButtonClose1");
			var VipButtonClose2:Class = ResourceHelper.getInstance().getClassByName("VipButtonClose2");
			var closeIcon:ImgSwitchIcon = new ImgSwitchIcon(VipButtonClose1, VipButtonClose2);
			closeIcon.x = 490;
			closeIcon.y = 15;
			addChild(closeIcon);
			closeIcon.addEventListener(MouseEvent.CLICK, onButtonCloseClick);
			//开通黄钻
			var vipButtonOpen:VipButtonOpen = new VipButtonOpen();
			vipButtonOpen.x = 250;
			vipButtonOpen.y = 415;
			addChild(vipButtonOpen);
			//开通年费黄钻
			var vipButtonOpenYear:VipButtonOpenYear = new VipButtonOpenYear();
			vipButtonOpenYear.x = 380;
			vipButtonOpenYear.y = 415;
			addChild(vipButtonOpenYear);
			var objectConfig:ObjConfig;
			var ObjectImage:Class;
			var objectSprite:Sprite;
			var objectTitleText:TextField;
			var objectNumText:TextField;
			//顶部文字
			var topTitleText:TextField = new TextField();
			topTitleText.selectable = false;
        	topTitleText.autoSize = TextFieldAutoSize.LEFT;
			topTitleText.defaultTextFormat = new TextFormat("微软雅黑", 15, 0x8F470E, true);
			topTitleText.width = 200;
			topTitleText.text = "成为黄钻贵族，每天将获得黄钻等级礼包，等级越高礼包越大。\n更有黄钻活动特权、升级双倍奖励、全场商品8折等特权让你享乐不停！";
			topTitleText.x = 35;
			topTitleText.y = 60;
			addChild(topTitleText);
			//每日礼物
			for (var i:int = 0; i < 7; i++)
			{
				var dailyPresentStrs:Array = dailyPresent[i].split(",");
				var dailyPresent:Sprite = new Sprite();
				var VipIconImg:Class = ResourceHelper.getInstance().getClassByName("VipIcon" + (i + 1));
				var vipIcon:Sprite = new VipIconImg();
				vipIcon.width = 30;
				vipIcon.scaleY = vipIcon.scaleX;
				vipIcon.x = 20;
				dailyPresent.addChild(vipIcon);
				for (var j:int = 0; j < dailyPresentStrs.length; j++)
				{
					var presentStrs:Array = dailyPresentStrs[j].split("_");
					var objectIndex:int = presentStrs[0];
					var objectNum:int = presentStrs[1];
					objectConfig = Config.objConfigs[objectIndex];
					//物品图片
					ObjectImage = ResourceHelper.getInstance().getClassByName(objectConfig.iconImage[0]);
					objectSprite = new ObjectImage();
					objectSprite.width = 30;
					objectSprite.scaleY = objectSprite.scaleX;
					objectSprite.x = 140 * j + 75;
					objectSprite.y = -5;
					dailyPresent.addChild(objectSprite);
					//物品名字
					objectTitleText = new TextField();
					objectTitleText.selectable = false;
		        	objectTitleText.autoSize = TextFieldAutoSize.LEFT;
					objectTitleText.defaultTextFormat = new TextFormat("微软雅黑", 12, 0x8F470E);
					objectTitleText.x = 140 * j + 112;
					objectTitleText.y = 0;
					objectTitleText.text = objectConfig.name + "×" + objectNum;
					dailyPresent.addChild(objectTitleText);
				}
				dailyPresent.mouseChildren = false;
				dailyPresent.x = 25;
				dailyPresent.y = i * 34 + 178;
				addChild(dailyPresent);
			}
			var yearPresent:Sprite = new Sprite();
			//年费礼物
			objectConfig = Config.objConfigs[CardConfig.ANGEL_BIG];
			//物品图片
			ObjectImage = ResourceHelper.getInstance().getClassByName(objectConfig.iconImage[0]);
			objectSprite = new ObjectImage();
			objectSprite.width = 100;
			objectSprite.scaleY = objectSprite.scaleX;
			objectSprite.x = 5;
			yearPresent.addChild(objectSprite);
			//物品名字
			objectTitleText = new TextField();
			objectTitleText.selectable = false;
        	objectTitleText.autoSize = TextFieldAutoSize.LEFT;
			objectTitleText.defaultTextFormat = new TextFormat("微软雅黑", 18, 0x8F470E, true);
			objectTitleText.x = 15;
			objectTitleText.y = 120;
			objectTitleText.text = objectConfig.name;
			yearPresent.addChild(objectTitleText);
			//物品个数
			objectNumText = new TextField();
			objectNumText.selectable = false;
        	objectNumText.autoSize = TextFieldAutoSize.LEFT;
			objectNumText.defaultTextFormat = new TextFormat("微软雅黑", 18, 0x8F470E, true);
			objectNumText.x = 30;
			objectNumText.y = 140;
			objectNumText.text = "×1";
			yearPresent.addChild(objectNumText);
			yearPresent.mouseChildren = false;
			yearPresent.x = 400;
			yearPresent.y = 230;
			addChild(yearPresent);
			this.anchor = BasicWidget.ANCHOR_MIDDLE_MIDDLE;
			this.x = -this.width / 2;
			this.y = -this.height / 2;
		}
		
		public function onButtonCloseClick(event:MouseEvent):void
		{
			close();
		}
	}
}